package com.my.code.phaser;

/**
 * 比赛开始
 */
public class RunnerGame {
    public static void main(String[] args) {
        int runnerNum = 4;

        GamePhaser gamePhaser = new GamePhaser();

        //注册一次表示phaser维护的线程个数
        gamePhaser.register();
        for (int i = 0; i < runnerNum; i++) {
            //注册一次表示phaser维护的线程个数
            gamePhaser.register();
            new Thread(new Runner(gamePhaser)).start();
        }

        //后续阶段主线程就不参加了
        gamePhaser.arriveAndDeregister();

    }
}
